﻿
#region Usings

using FasterWPF;
using FasterWPFDemo.UserControls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Media3D;
using System.Windows.Shapes;
using wpfToolkit = Xceed.Wpf.Toolkit;
using Thriple.Controls;
using System.Windows.Controls.Primitives;
using FasterWPFExtras;
using System.Windows.Documents;
using System.Windows.Markup;
using FasterWPF.Selectors;
using System.Reactive;
using System.Reactive.Linq;
#endregion

namespace FasterWPFDemo
{
    public class BrushTest : DependencyObject
    {
        public Brush BrushProperty
        {
            get { return (Brush)GetValue(BrushPropertyProperty); }
            set { SetValue(BrushPropertyProperty, value); }
        }

        // Using a DependencyProperty as the backing store for BrushProperty.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty BrushPropertyProperty =
            DependencyProperty.Register("BrushProperty", typeof(Brush), typeof(BrushTest), new PropertyMetadata(Brushes.White));
    }

    public partial class TabItem10 : UserControl, IUserControlGuid
    {
        private string _userCtlGuid = null;

        public string UserControlGuid
        {
            get
            {
                return _userCtlGuid;
            }

            set
            {
                _userCtlGuid = value;
            }
        }

        public TabItem10()
        {
            //InitializeComponent(); XAML removed. Initialize via code-behind.

            this.Initialize(ContainerType.VerticalPanel);


            // this.Width = 850D;
            // this.Height = 750D;

            this.BeginSettings<UserControl>()
                .SetSelectorClass<UserControl>(0, 0, "tabLabel")
                .SetItemBorderColorAndThickness<UserControl>(Brushes.Gray, new Thickness(0)).EndSettings();
        }

        PerspectiveCamera _defaultCameraPrototype = null;
        PerspectiveCamera DefaultCameraPrototype
        {
            get
            {
                if (_defaultCameraPrototype == null)
                {
                    _defaultCameraPrototype = new PerspectiveCamera
                    {
                        Position = new Point3D(0, 0, 1.2),
                        LookDirection = new Vector3D(0, 0, -1),
                        FieldOfView = 80
                    };
                }
                return _defaultCameraPrototype;
            }
        }

        private Travel currentEntity = null;

        public void LoadUserControl()
        {
            Canvas userControlCanvas = new Canvas();
            userControlCanvas.Initialize(ContainerType.ContentControlPanel);
        
            //Brush imageBrush = BrushExt.CreateImageBrush(@"pack://siteoforigin:,,,/Images/lake.bmp", UriKind.Absolute, 100D);
            Brush radialGradientBrush = BrushExt.CreateRadialGradientBrush("#FF002050", 0D, 132, 145, 181, 50, .34D, .5D, .9D, .1D, .9D);
            StackPanel horizPanel = Factory.InitStackPanel(ContainerType.HorizontalPanel, Orientation.Horizontal, radialGradientBrush, 1, 1);
            horizPanel.BeginSettings<StackPanel>().Set<Border, StackPanel>("Margin", new Thickness(35, 0, 0, 0))
               // .SetItemBorderSettings<StackPanel>(Double.NaN,Double.NaN, Brushes.White, new Thickness(2))
                .EndSettings<StackPanel>();

            string stkcpanel2Guid = Guid.NewGuid().ToString();
            StackPanel stkcpanel2 = Factory.InitStackPanel(ContainerType.VerticalPanel, Orientation.Horizontal, Brushes.Transparent, 1, 1);
            string stkcpanel3Guid = Guid.NewGuid().ToString();
            StackPanel stkcpanel3 = Factory.InitStackPanel(Double.NaN, 794D, ContainerType.VerticalPanel, Orientation.Horizontal, Brushes.Transparent); 

            string cc3DGuid = Guid.NewGuid().ToString();
            ContentControl3D ccl3d = new ContentControl3D();
            ccl3d.Padding = new Thickness(0);
            ccl3d.Margin = new Thickness(13, 13, 0, 0);
            ccl3d.Initialize(431D, 431D, ContainerType.Grid, Brushes.Black, new Thickness(2), BrushExt.CreateSolidColorBrushFromRGB(30, 30, 30, 50), RotationEasingMode.Pounce, RotationDirection.BottomToTop);
            ccl3d.SetCompositeGridDimensions<ContentControl3D>(17, 4, 0.33, GridUnitType.Auto, 100, GridUnitType.Auto);

            ccl3d.CameraPrototype = DefaultCameraPrototype;
            ccl3d.BeginSettings<ContentControl3D>()
                .SetUseLayoutRounding<ContentControl3D>(true)
                //.SetSelectorClassToRow<ContentControl3D>(1, 0, 2, "redlabel")
                .Set<Label, ContentControl3D>(0, 0, "Background", Brushes.WhiteSmoke)
                .Set<TextBox, ContentControl3D>(1, 1, "Text", "")
                .Set<TextBox, ContentControl3D>(2, 1, "Text", "")
                .SetFontToColForLabel(0, 0, 16, "Arial", 11, FontWeights.Bold, FontStyles.Normal)
                .Set<TextBox, ContentControl3D>("MaxHeight", 33D)
                .Set<Label, ContentControl3D>("MaxHeight", 33D)
                .Set<TextBox, ContentControl3D>("MaxWidth", 137D)
                .Set<wpfToolkit.DecimalUpDown, ContentControl3D>("MaxWidth", 137D)
                .Set<ComboBox, ContentControl3D>("MaxWidth", 137D)
                .Set<DatePicker, ContentControl3D>("MaxWidth", 137D)
                .Set<wpfToolkit.MaskedTextBox, ContentControl3D>("MaxWidth", 137D)
                .Set<ComboBox, ContentControl3D>("Margin", new Thickness(1, 1, 1, 3))
                .Set<Label, ContentControl3D>("Margin", new Thickness(1, 1, 1, 3))
                .Set<TextBox, ContentControl3D>("Margin", new Thickness(1, 1, 1, 3))
                .Set<wpfToolkit.DecimalUpDown, ContentControl3D>("Margin", new Thickness(1, 1, 1, 3))
                .Set<DatePicker, ContentControl3D>("Margin", new Thickness(1, 1, 1, 3))
                .Set<wpfToolkit.MaskedTextBox, ContentControl3D>("Margin", new Thickness(1, 1, 1, 3))
                .SetAttachedProperty<Label, ContentControl3D>("ColumnSpan", 0, 0, 
                 obj => { obj.SetValue(Grid.ColumnSpanProperty, 4); })
                .Set<DatePicker, ContentControl3D>(13, 1, "Background", Brushes.WhiteSmoke)
                .SetToCol<Label, ContentControl3D>(0, 1, 15, "HorizontalContentAlignment", HorizontalAlignment.Right)
                .SetVerticalAlignment<ContentControl3D>(0, 1, VerticalAlignment.Center)
                .SetVerticalAlignment<ContentControl3D>(0, 2, VerticalAlignment.Center)
                .SetVerticalAlignment<ContentControl3D>(2, 1, VerticalAlignment.Bottom)
                .SetVerticalAlignment<ContentControl3D>(3, 1, VerticalAlignment.Top)
                .SetToCol<Label, ContentControl3D>(0, 4, 15, "VerticalAlignment", VerticalAlignment.Center)
            //   .SetToRow<FrameworkElement, ContentControl3D>(1, 0, 3, "Height", 30D)
                .SetItemBorderColorAndThickness(Brushes.Blue, new Thickness(0))
                .EndSettings<ContentControl3D>();

            string gridguid1 = null;
            gridguid1 = Guid.NewGuid().ToString();
            ComboBox cb1 = SetupComboBox();
            
            //Additional Comments Multi-Line TextBox
            TextBox trex = new TextBox();
            trex.InitializeForScrollViewerSupport(350D, 350D, 140D);  //TextBox is NOT an IParent but it is an IScrollViewerStrategy.
            ScrollViewerStyle.ApplyToScrollViewer<TextBox>(trex, "PowderBlue", "White", "Blue");
            trex.SetValue(Grid.RowSpanProperty, 9);
            trex.SetValue(Grid.ColumnSpanProperty, 3);        
            trex.Text = "This is an example\n of a\n multi-line textbox.";

            Brush reuseBrush = BrushExt.CreateGradientBrush(254, 254, 254, 50, 0, 0, 32, 80, 100, .93, 1, 1, 0, 0);

            //FRONT SIDE
            Border ccl3dBorder1 = ccl3d.BeginComposite<ContentControl3D>(gridguid1)
                 .AddLabel<ContentControl3D>(0, 0, "Front Side: Click Here to Rotate", Brushes.Transparent)
                 .SubscribeEventOnChild<Label, ContentControl3D, MouseButtonEventArgs>(0, 0, "PreviewMouseDown", ((o, ev) =>
                 {
                     ccl3d.Rotate();
                 }))
                   .AddLabel<ContentControl3D>(1, 0, "Attraction:", reuseBrush)
                   .AddLabel<ContentControl3D>(2, 0, "Location:", reuseBrush)
                   .AddLabel<ContentControl3D>(4, 0, "Flight:", reuseBrush)
                   .AddLabel<ContentControl3D>(5, 0, "Hotel:", reuseBrush)
                   .AddLabel<ContentControl3D>(3, 0, "Parking Garage Color:", reuseBrush)
                   .AddLabel<ContentControl3D>(6, 0, "Currency (Max $999.99):", reuseBrush)
                   .AddLabel<ContentControl3D>(7, 0, "Percent (Max 100.00):", reuseBrush)
                   .AddLabel<ContentControl3D>(8, 0, "Rental Car Company:", reuseBrush)
                   .AddLabel<ContentControl3D>(9, 0, "Reason for Travel:", reuseBrush)
                  // .AddLabel<ContentControl3D>(10, 0, "Children:", reuseBrush)
                   .AddLabelSettingBackgroundViaStyle<ContentControl3D>(10, 0, "Children:", reuseBrush)
                   .AddLabel<ContentControl3D>(11, 0, "Favorite Sport:", reuseBrush)
                   .AddLabel<ContentControl3D>(12, 0, "Favorite Food:", reuseBrush)
                   .AddLabel<ContentControl3D>(13, 0, "Date of Travel:", reuseBrush)
                   .AddLabel<ContentControl3D>(14, 0, "Phone Number:", reuseBrush)
                   .AddNumericTextBox<ContentControl3D>(6, 1, 139D, 23D, 299.99M, 999.99M, 0.00M, 1.00M, "C2", true)
                   .ModifyAtXY<wpfToolkit.DecimalUpDown, ContentControl3D>(6, 1, de => { de.SetSelectorClass("decimalControl"); })
                   .AddNumericTextBox<ContentControl3D>(7, 1, 139D, 23D, .99M, 1.00M, 0.00M, .010M, "P2", true)
                   .ModifyAtXY<wpfToolkit.DecimalUpDown, ContentControl3D>(7, 1, de => { de.SetSelectorClass("decimalControl"); })
                   .AddAnything<TextBox, ContentControl3D>(1, 1).ModifyAtXY<TextBox, ContentControl3D>(1, 1, k => { k.Text = "hello world!"; k.Background = Brushes.Gold; })
                   .AddAnything<TextBox, ContentControl3D>(2, 1)
                   .AddExisting<ComboBox, ContentControl3D>(3, 1, cb1)
                   .AddAnything<TextBox, ContentControl3D>(4, 1)
                   .AddAnything<TextBox, ContentControl3D>(5, 1)
                   .AddAnything<TextBox, ContentControl3D>(8, 1)
                   .AddAnything<TextBox, ContentControl3D>(9, 1)

                  .DataBindOneChildsPropertyToAnother<Label, TextBox, ContentControl3D>(10, 0, 9, 1, Label.ContentProperty, TextBox.TextProperty, System.Windows.Data.UpdateSourceTrigger.PropertyChanged, System.Windows.Data.BindingMode.OneWay)
                  
                   .AddAnything<TextBox, ContentControl3D>(10, 1)
                   .AddAnything<TextBox, ContentControl3D>(11, 1)
                   .AddAnything<TextBox, ContentControl3D>(12, 1)             
                   .AddAnything<DatePicker, ContentControl3D>(13, 1)
                   .AddFixedLengthMaskedTextBox<ContentControl3D>(14, 1, "(219) 999-9999", "(000) 000-0000", true, true)
                   .EndComposite(new ContentControl3DArgs(ContentControlEnum.Front));
            
         //   ccl3dBorder1.DataBindContainersPropertyToParents<Grid, ContentControl3D>(Grid.MarginProperty, ContentControl3D.MarginProperty, System.Windows.Data.UpdateSourceTrigger.PropertyChanged, System.Windows.Data.BindingMode.OneWay, new TestConverter());

            //BACK SIDE
            Border ccl3dBorder2 = ccl3d.BeginComposite<ContentControl3D>()
                 .AddLabel<ContentControl3D>(0, 0, "Back Side: Click Here to Rotate", Brushes.Transparent)
                 .AddLabel<ContentControl3D>(1, 0, "", Brushes.Transparent)
                 .AddLabel<ContentControl3D>(1, 1, "", Brushes.Transparent)
                 .AddLabel<ContentControl3D>(2, 0, "Additional Comments:", reuseBrush)
                 .AddExisting<TextBox, ContentControl3D>(3, 0, trex)
                 .AddLabel<ContentControl3D>(11, 0, "", Brushes.Transparent)
                 .AddLabel<ContentControl3D>(12, 0, "", Brushes.Transparent)
                 .AddLabel<ContentControl3D>(13, 0, "", Brushes.Transparent)
                 .AddLabel<ContentControl3D>(14, 0, "", Brushes.Transparent)
                 .AddLabel<ContentControl3D>(15, 0, "Special Needs:", reuseBrush)
                 .AddAnything<TextBox, ContentControl3D>(16, 0)
                 .SubscribeEventOnChild<Label, ContentControl3D, MouseButtonEventArgs>(0, 0, "PreviewMouseDown",(o, ev) =>
                 {
                     ccl3d.Rotate();
                 })
                 .EndComposite(new ContentControl3DArgs(ContentControlEnum.Back));
          
            //Override Settings
            ccl3dBorder1.GetChildFromComposite<Label, ContentControl3D>(0, 0).SetValue(Label.MinWidthProperty, 334D);
            ccl3dBorder1.GetChildFromComposite<Label, ContentControl3D>(0, 0).SetValue(Label.MinHeightProperty, 34D);

            ccl3dBorder2.GetChildFromComposite<Label, ContentControl3D>(0, 0).SetValue(Label.MinWidthProperty, 334D);
            ccl3dBorder2.GetChildFromComposite<TextBox, ContentControl3D>(16, 0).SetValue(Label.MinWidthProperty, 334D);
            ccl3dBorder2.GetChildFromComposite<TextBox, ContentControl3D>(3, 0).SetValue(Label.MinWidthProperty, 334D);
            ccl3dBorder2.GetChildFromComposite<Label, ContentControl3D>(0, 0).SetValue(Label.MinHeightProperty, 34D);
            ccl3dBorder2.GetChildFromComposite<Label, ContentControl3D>(2, 0).SetValue(Grid.ColumnSpanProperty, 3);
            ccl3dBorder2.GetChildFromComposite<Label, ContentControl3D>(15, 0).SetValue(Grid.ColumnSpanProperty, 4);
            ccl3dBorder2.GetChildFromComposite<TextBox, ContentControl3D>(16, 0).SetValue(Grid.ColumnSpanProperty, 4);
            ccl3dBorder2.GetChildFromComposite<Label, ContentControl3D>(2, 0).SetValue(Label.HorizontalContentAlignmentProperty, HorizontalAlignment.Center);
            ccl3dBorder2.GetChildFromComposite<Label, ContentControl3D>(15, 0).SetValue(Label.HorizontalContentAlignmentProperty, HorizontalAlignment.Center);
     
            #region Other

            var rect = new Rectangle()
            {
                Height = 250,
                Width = 350,
                Fill = new SolidColorBrush(Colors.LightBlue),
                Stroke = Brushes.Gray
            };

            string ccl3d1Key = ccl3dBorder1.GetKey();
            string ccl3d2Key = ccl3dBorder2.GetKey();

            // string userCtlGuid = Guid.NewGuid().ToString();

            ExampleUserControl usc = new ExampleUserControl(_userCtlGuid);
            UserControlRegion epres = new UserControlRegion(Brushes.White);
            string userControlRegionkey = epres.AddUserControl(usc);

            BuildAndStoreActions(usc, epres);

            //subscribe to mousesingleclick on any and all Composites (Borders)
            stkcpanel2.BeginSettings<StackPanel>().Set<Border, StackPanel>(0, 2, "Margin", new Thickness(10))
                //     .SubscribeMouseSingleClick<StackPanel>(new MouseButtonEventHandler((o,ev)=>{
                //     MessageBox.Show("hi");}))
             //   .SetItemBorderSettings<StackPanel>(Double.NaN,Double.NaN, Brushes.White, new Thickness(2))
                .SetTextColorForLabel<StackPanel>(0, 4, Brushes.White)
                .SetTextColorForLabel<StackPanel>(0, 6, Brushes.White)
                .EndSettings<StackPanel>();

            stkcpanel2.BeginComposite<StackPanel>(stkcpanel2Guid)
                 .AddExisting<ContentControl3D, StackPanel>(0, 3, ccl3d)
                 .AddLabel<StackPanel>(0, 4, "Click Rectangle below\nto re-size it via an Animation.", Brushes.Transparent)
                 .AddExisting<Rectangle, StackPanel>(0, 5, rect)

                 //Subscribe to MouseSingleClick on Rectangle
                 .SubscribeMouseSingleClickOnChild<Rectangle, StackPanel>(0, 5, (o, ev) =>
                 {
                     if (rect.ActualHeight == 50D)
                     {
                         rect.DoubleAnimate(Rectangle.WidthProperty, 50, 150, TimeSpan.FromSeconds(3.0), false, false);
                         rect.DoubleAnimate(Rectangle.HeightProperty, 50, 150, TimeSpan.FromSeconds(3.0), false, false);
                     }
                     else
                     {
                         if (rect.ActualHeight == 250D)
                         {
                             rect.DoubleAnimate(Rectangle.WidthProperty, 350, 50, TimeSpan.FromSeconds(3.0), false, false);
                             rect.DoubleAnimate(Rectangle.HeightProperty, 250, 50, TimeSpan.FromSeconds(3.0), false, false);
                         }
                         else
                         {
                             //longhand version
                             DoubleAnimation myDoubleAnimation = new DoubleAnimation();
                             myDoubleAnimation.From = 150;
                             myDoubleAnimation.To = 50;
                             myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(3.0));
                             myDoubleAnimation.AutoReverse = false;

                             rect.BeginAnimation(Rectangle.WidthProperty, myDoubleAnimation);
                             rect.BeginAnimation(Rectangle.HeightProperty, myDoubleAnimation);
                         }
                     }
                 })
                 .AddLabel<StackPanel>(0, 6, "Below is a re-usable UserControl in a UserControlRegion (Border).", Brushes.Transparent)
                 .AddExisting<Border, StackPanel>(0, 7, epres) //Add UserControl via a Border "region"
                 .EndComposite<StackPanel, StackPanelArgs>(null);

            //  stkcpanel2.UnsubscribeMouseSingleClickOnChild<StackPanel>(stkcpanel2Guid, 0, 5);

            #endregion

           //TO achieve a ContextMenu, get a handle to the Canvas and add an element on there.                  //very similar to a modal dialog
           // MenuItemExt.DisplaySubMenu(cnvs, cnvsguid2, subMenuBorder, 88D, 21D, 500);
           // MenuItemExt.HideSubMenu(cnvs, cnvsguid3);



            stkcpanel3.VerticalAlignment = VerticalAlignment.Top;
            stkcpanel3.BeginSettings<StackPanel>()
                //.SetItemBorderSettings<StackPanel>(Double.NaN, 800D, Brushes.White, new Thickness(2))
                .SetFontOnLabel<StackPanel>(0, 1, "Segoe UI", 30, FontWeights.Bold, FontStyles.Normal)
                .Set<Label, StackPanel>(0, 1, "Margin", new Thickness(20, 30, 0, 14))
                //.Set<Image, StackPanel>(0, 2, "Margin", new Thickness(30, 30, 0, 14))
                .Set<TextBlock, StackPanel>(0, 5, "Padding", new Thickness(20, 30, 0, 14))
                .SetTextColorForLabel<StackPanel>(0, 1, BrushExt.CreateSolidColorBrushFromString("#FF002050"))
                .Set<Border, StackPanel>(0, 3, "HorizontalAlignment", HorizontalAlignment.Left)
                .SetItemBorderSettings(Double.NaN, 800D, Brushes.Transparent, new Thickness(1)) 
                .SetTextColor(0, 5, Brushes.Black)
                .SetFont(0, 5,"Tahoma", 20, FontWeights.Bold, FontStyles.Normal)
                .EndSettings<StackPanel>();

            stkcpanel3.BeginComposite<StackPanel>(stkcpanel3Guid)
                .AddLabel<StackPanel>(0, 1, "XYZ Travel Application", Brushes.Transparent)
                .AddExisting<Border, StackPanel>(0, 2, ImageFlipper.CreateImageFlipper(300D, 207D, 1750D, new Thickness(10), Brushes.Black, new Thickness(3), Brushes.Silver, new Thickness(2), Brushes.White, 30D, @"pack://siteoforigin:,,,/Images/Bldgs1.jpg", UriKind.Absolute, @"pack://siteoforigin:,,,/Images/Bldgs2.jpg", UriKind.Absolute, 13D, new Thickness(4, 0, 4, 0), Brushes.LightGray, Brushes.Khaki))
               // .AddImage<StackPanel>(0, 2, @"pack://siteoforigin:,,,/Images/lakealpha.png", UriKind.Absolute, 317D )
                .AddFlatButton<StackPanel>(0, 3, 175D, 87D,
                "Click here to\nadd ORD to Flight Field\nand XYZ Hotel to Hotel Field\nand Vegetarian to Special Needs", Brushes.GhostWhite, new Thickness(2), BrushExt.CreateSolidColorBrushFromString("#FF002050"), new CornerRadius(3), new Thickness(2), new Thickness(100, 0, 0, 0), Brushes.LightSlateGray, Brushes.White, Brushes.White,
                (o, ev) =>
                {
                    ccl3dBorder1.GetChildFromComposite<TextBox, ContentControl3D>(4, 1).Text = "ORD";
                    ccl3dBorder1.GetChildFromComposite<TextBox, ContentControl3D>(5, 1).Text = "XYZ Hotel";
                    ccl3dBorder2.GetChildFromComposite<TextBox, ContentControl3D>(16, 0).Text = "Vegetarian";
                })
                .AddText(0, 4,"")
                .AddText(0, 5, "MASTER-DETAIL EXAMPLE: \nClick on master record at \nright, partial detail will \nbe shown in Form at left.")
                //nest a new IParent ContentControl with a UniformGridComposite, instantiating it on-the-fly . . .
                .AddAnyIParent<ContentControl, StackPanel>(0, 6, myIParent =>
                {
                   myIParent.Initialize(ContainerType.UniformGrid, Brushes.LightGray, new Thickness(3));
                   myIParent.SetCompositeUniformGridSettings(1, 2, 300, 100);
                   myIParent.BeginSettings()
                       .SetFontOnLabel(0, 0, "Arial", 12, FontWeights.DemiBold, FontStyles.Italic)
                       .EndSettings();
                    //count?
                   var unfBorder = myIParent.BeginComposite()
                       .AddLabel(0, 0, "This is a:", Brushes.LightSteelBlue)
                       .AddLabel(0, 1, "UniformGrid", Brushes.LightGray)
                       .EndComposite<ContentControl, ContentControlArgs>(null);

                   unfBorder.Margin = new Thickness(0, 0, 0, 25);
                })
                .AddAnyIParent<StackPanel, StackPanel>(0, 7, myStkPanel =>
                {
                                    myStkPanel.Initialize(100, 200, ContainerType.Canvas, Orientation.Vertical);
                                   
                                    //Set Default Colors
                                    myStkPanel.SetCompositeCanvasSettings(100, 50, Brushes.Aqua, Brushes.Wheat);
                                    myStkPanel.Background = Brushes.LightSlateGray;
                                    myStkPanel.Opacity = .59;
                                    myStkPanel.BeginSettings()
                                        .SetTextColorForLabel(30, 35, Brushes.White)
                                        .SetZIndex<Label, StackPanel>(10, 25, 2)
                                        .SetFontOnLabel(10, 10, "Arial", 11, FontWeights.DemiBold, FontStyles.Normal)
                                        .SetFontOnLabel(30, 10, "Arial", 11, FontWeights.DemiBold, FontStyles.Italic)
                                        .SetFontOnLabel(10, 25, "Arial", 14, FontWeights.Bold, FontStyles.Normal)
                                        .SetFontOnLabel(30, 35, "Arial", 14, FontWeights.Bold, FontStyles.Italic)
                                        .EndSettings();
                   
                                   Border xty = myStkPanel.BeginComposite()
                                        .AddLabel(10, 10, "This is a Canvas #1:", Brushes.LightSteelBlue)
                                        .AddLabel(30, 10, "in a Vertical StackPanel", Brushes.Plum)
                                        .EndComposite<StackPanel, StackPanelArgs>(null);
                                   
                                   //Override Default Colors
                                   myStkPanel.GetContainerFromComposite<Canvas, StackPanel>(myStkPanel.GetCompositeFromParent(xty.GetKey())).SetBackgroundColor(Brushes.LightSlateGray);
                                   myStkPanel.GetContainerFromComposite<Canvas, StackPanel>(myStkPanel.GetCompositeFromParent(xty.GetKey())).SetMouseOverColor(Brushes.Orange);
                                 
                                   myStkPanel.BeginComposite()
                                            .AddLabel(10, 25, "This is a Canvas #2:", Brushes.LightSteelBlue)
                                            .AddLabel(30, 35, "in a Vertical StackPanel", Brushes.Blue)
                                            .EndComposite<StackPanel, StackPanelArgs>(null);
                }) 
               .EndComposite<StackPanel, StackPanelArgs>(null);

            horizPanel.BeginComposite<StackPanel>()
                .AddExisting<StackPanel, StackPanel>(0, 0, stkcpanel2)
                .AddExisting<StackPanel, StackPanel>(0, 1, stkcpanel3)
                .EndComposite<StackPanel, StackPanelArgs>(null);

            userControlCanvas.BeginComposite<Canvas>()
                  .AddExisting<StackPanel, Canvas>(0, 0, horizPanel)
                  .EndComposite<Canvas, CanvasArgs>(new CanvasArgs(0, 0, 1));

            DataGrid masterDetail = new DataGrid();

            masterDetail.Initialize(397D, 810D, ContainerType.VerticalPanel, Brushes.WhiteSmoke, Brushes.Gray, Brushes.Gray, new Thickness(0));
            masterDetail.BeginSettings().SetBackgroundColorOnItemsControl(Brushes.LightSlateGray).SetItemBorderColorAndThickness(Brushes.LightSteelBlue, new Thickness(0)).Set<TextBlock, DataGrid>("Padding", new Thickness(2,0,2,0)).SetTextColor(0, 1, Brushes.Black).EndSettings();
            masterDetail.BorderBrush = Brushes.Black;
            masterDetail.BorderThickness = new Thickness(0);
        
            masterDetail.ApplyScrollViewerStrategy("LightSteelBlue", "LightSkyBlue", "#FF002050");

            List<string> columnHeaderList = new List<String>();
            columnHeaderList.Add(" Attractions");
            columnHeaderList.Add(" Parking Garage");

            int itrv = 0;
            List<Travel> listOfTravelItems;
            listOfTravelItems = new List<Travel>();
            Enumerable.Range(0, 100).ToList().ForEach(x => { itrv = populateTravelEntities(listOfTravelItems, itrv, x); });


            //App.Current.MainWindow top then down

            masterDetail.ApplyDataGridStrategy(20, DataGridSelectionMode.Single, DataGridSelectionUnit.FullRow, Brushes.LightSteelBlue, Brushes.LightSkyBlue, Brushes.Black, Brushes.LightSkyBlue, "Gray", "Silver", "1,1,1,1", 1D, "Gray", "Silver", "Gray", "LightSkyBlue", "Gray");


            #region Add Context Menu to Grid

            ContextMenu cme = new ContextMenu();
            MenuItem item1 = new MenuItem();
            MenuItem item2 = new MenuItem();
            MenuItem item3 = new MenuItem();
            MenuItem item4 = new MenuItem();

            item1.Header = "Say Hello";
            item1.Click += new RoutedEventHandler((o, e)=>{
                 MessageBox.Show("hello");
            });
            cme.Items.Add(item1);

            item2.Header = "Scroll to First Item in Grid";
            item2.Click += new RoutedEventHandler((o, e)=>{
                scrollToFirstItemInGrid(ccl3dBorder1, masterDetail);
            });
            cme.Items.Add(item2);

            item3.Header = "Scroll to Last Item in Grid";
            item3.Click+= new RoutedEventHandler((o, e)=>{
                scrollToLastItemInGrid(ccl3dBorder1, masterDetail);
            });
            item3.IsCheckable = true;
            item3.Checked += new RoutedEventHandler((o, e) =>
            {
                MessageBox.Show("I have been checked!");
            });
            item3.Unchecked += new RoutedEventHandler((o, e) =>
            {
                MessageBox.Show("I have been unchecked!");
            });
            cme.Items.Add(item3);

            item4.Header = "Say Goodbye";
            item4.Click += new RoutedEventHandler((o, e) =>
            {
                MessageBox.Show("goodbye");
            });
            cme.Items.Add(item4);

            cme.ApplyContextMenuStrategy("White", "SlateGray", new Thickness(2), "Black", "LightBlue", "LightBlue", "Gray", item1, item2, item3, item4);
            masterDetail.ContextMenu = cme;

            #endregion


            masterDetail.SubscribeSelectionChangedOnParent((o, e) => {

                //ON SELECTION CHANGED, UPDATE THE DETAIL RECORD
                DataGridRow selectedRow = masterDetail.GetSelectedRow();
                if (selectedRow != null)
                {
                    var cells = selectedRow.Item as ColumnContent<Border, Border, Border, Border, Border, Border, Border, Border, Border, Border, Border>;
                    Border contentAtCol0 = cells.Content0.Content as Border;
                    Border contentAtCol1 = cells.Content1.Content as Border;

                    char colon = ':';

                    //NOTE: y/column is the index for StackPanel. x/row is ignored.

                    string flight = contentAtCol0.GetChildFromComposite<TextBlock, DataGrid>(0, 1).GetText().Split(colon)[1].Trim();
                    string hotel = contentAtCol0.GetChildFromComposite<TextBlock, DataGrid>(0, 2).GetText().Split(colon)[1].Trim();
                    string attraction = contentAtCol0.GetChildFromComposite<TextBlock, DataGrid>(0, 3).GetText().Split(colon)[1].Trim();
                    string parking = contentAtCol1.GetChildFromComposite<TextBlock, DataGrid>(0, 0).GetText().Split(colon)[1].Trim();

                    ccl3dBorder1.GetChildFromComposite<TextBox, ContentControl3D>(1, 1).Text = attraction;
                    ccl3dBorder1.GetChildFromComposite<ComboBox, ContentControl3D>(3, 1).Text = parking;
                    ccl3dBorder1.GetChildFromComposite<TextBox, ContentControl3D>(4, 1).Text = flight;
                    ccl3dBorder1.GetChildFromComposite<TextBox, ContentControl3D>(5, 1).Text = hotel;
                }
             });

            //char underscoreChar = '_';
            listOfTravelItems.ForEach(trav =>
            {
                if (trav.Counter == 0)  //add column header list when adding the first composite
                {                   
                    //NOTE: y/column is the index for StackPanel. x/row is ignored.
             
                    //Column 1
                    var borderA = masterDetail.BeginComposite<DataGrid>(trav.ID + "1")
                            .AddText(0, 0, trav.Counter.ToString())
                            .AddText(0, 1, "Flight: " + trav.Flight)
                            .AddText(0, 2, "Hotel: " + trav.Hotel)
                            .AddText(0, 3, "Attraction: " + trav.Attraction)
                            .SetMouseOverColorOnContainer<StackPanel, DataGrid>(Brushes.Silver)
                            .EndComposite<DataGrid, DataGridArgs>(new DataGridArgs(trav.ID, 0, 0, columnHeaderList));

                    //Column 2
                    masterDetail.BeginComposite<DataGrid>(trav.ParkingGarages[0].ID + "2")
                            .AddText(0, 0, "Color: " + trav.ParkingGarages[0].Color)
                            .AddText(0, 1, "Description: " + trav.ParkingGarages[0].Description)
                            .AddText(0, 2, " ")
                            .SetMouseOverColorOnContainer<StackPanel, DataGrid>(Brushes.Silver)
                            .EndComposite<DataGrid, DataGridArgs>(new DataGridArgs(trav.ParkingGarages[0].ID, 0, 1, columnHeaderList));
                            

                    masterDetail.UpdateByKey<TextBlock, DataGrid>(borderA.GetKey(), 0, 0, txt => { txt.FontWeight = FontWeights.Bold; });
                }
                else
                {
                    Border borderB = null;

                    if (trav.Flight == "SEA")
                    {
                        masterDetail.ChangeSetting<TextBlock, DataGrid>(0, 1, "Foreground", Brushes.Black);

                        //Column 1
                        borderB = masterDetail.BeginComposite<DataGrid>(trav.ID + "1")
                                .AddText(0, 0, trav.Counter.ToString())
                                .AddText(0, 1, "Flight: " + trav.Flight)
                                .AddText(0, 2, "Hotel: " + trav.Hotel)
                                .AddText(0, 3, "Attraction: " + " " + trav.Attraction)
                                .AddLabel(0, 4, "Vary for SEA", Brushes.Transparent)

                                .SetMouseOverColorOnContainer<StackPanel, DataGrid>(Brushes.Silver)
                                .ModifyAtXY<Label, DataGrid>(0, 4, q => { q.SetTrigger(typeof(Label), ForegroundProperty, Brushes.Yellow, Control.IsMouseOverProperty, true); q.Visibility = Visibility.Collapsed; })
                                .EndComposite<DataGrid, DataGridArgs>(new DataGridArgs(trav.ID, trav.Counter.Value, 0));

                        masterDetail.ChangeSetting<TextBlock, DataGrid>(0, 1, "Foreground", Brushes.Black);

                        masterDetail.UpdateByKey<TextBlock, DataGrid>(borderB.GetKey(), 0, 0, txt => { txt.FontWeight = FontWeights.Bold; });
                    }
                    else
                    {
                        //Column 1
                       var borderC = masterDetail.BeginComposite<DataGrid>(trav.ID + "1")
                                .AddText(0, 0, trav.Counter.ToString())
                                .AddText(0, 1, "Flight: " + trav.Flight)
                                .AddText(0, 2, "Hotel: " + trav.Hotel)
                                .AddText(0, 3, "Attraction: " + " " + trav.Attraction)
                                .SetMouseOverColorOnContainer<StackPanel, DataGrid>(Brushes.Silver)
                                .EndComposite<DataGrid, DataGridArgs>(new DataGridArgs(trav.ID, trav.Counter.Value, 0));
                       masterDetail.UpdateByKey<TextBlock, DataGrid>(borderC.GetKey(), 0, 0, txt => { txt.FontWeight = FontWeights.Bold; });
                    }

                    //if (borderB != null)
                    //{
                        //Column 2
                        var borderD = masterDetail.BeginComposite<DataGrid>(trav.ParkingGarages[0].ID + "2")
                                .AddText(0, 0, "Color: " + trav.ParkingGarages[0].Color)
                                .AddText(0, 1, "Description: " + trav.ParkingGarages[0].Description)
                                .AddText(0, 2, " ")
                               // .AddLabelSettingBackgroundViaStyle(0, 3, "Test", Brushes.Red)
                                .SetMouseOverColorOnContainer<StackPanel, DataGrid>(Brushes.Silver)
                                .ModifyAtXY<TextBlock, DataGrid>(0, 0, q => { q.Background = Brushes.Transparent; })
                                .EndComposite<DataGrid, DataGridArgs>(new DataGridArgs(trav.ParkingGarages[0].ID, trav.Counter.Value, 1));
                        
                        //Label lll = borderB.GetChildFromComposite<Label, DataGrid>(0, 4);
                        //borderD.GetChildFromComposite<Label, DataGrid>(0, 3).DataBindOneChildsPropertyToFE<Label, DataGrid>(lll, Label.BackgroundProperty, Border.BackgroundProperty, System.Windows.Data.UpdateSourceTrigger.PropertyChanged, System.Windows.Data.BindingMode.OneWay);

                        //lll.Background = Brushes.Purple;
                    //}
                }
            });

            //set column setting after column header list has been added
            masterDetail.Columns[0].MinWidth = 100D;
            masterDetail.Columns[1].MinWidth = 90D;
            masterDetail.SetBackgroundColor(BrushExt.CreateSolidColorBrushFromString("#FF002050"));

            //Column Header Colors
            masterDetail.SetColumnHeaderForeground(Brushes.White);
            masterDetail.SetColumnHeaderColor(BrushExt.CreateSolidColorBrushFromString("#FF002050"));


            masterDetail.SetSelectorClass("foo");

            Label myTabLabel = new Label(){ Content = "Tab Item 10 - Content Control 3D and Animation Example", Background = BrushExt.CreateGradientBrush("#FF002050", 0, "Silver", 1, .5D, .5D, 1D, 1D) };
            myTabLabel.Foreground = Brushes.White;

            Label myHelp = new Label(){ Content = "You could place\nhelp text here . . .", Background = Brushes.Khaki};
            myHelp.Width = 134D;
            myHelp.Height = 3000D;

            Popup pop1 = new Popup();

            userControlCanvas.BeginComposite<Canvas>()
            .AddExisting(0, 0, masterDetail)
            .EndComposite<Canvas, CanvasArgs>(new CanvasArgs(817, 0, 1));

            
            Border borderwithRectangle = userControlCanvas.BeginComposite<Canvas>()
           .AddAnything<Rectangle, Canvas>(0, 0).ModifyAtXY<Rectangle, Canvas>(0, 0, rect2 => { rect2.Width = 22D; rect2.Height = 14D; rect2.Fill = BrushExt.CreateSolidColorBrushFromString("#FF002050"); })
           .EndComposite<Canvas, CanvasArgs>(new CanvasArgs(817, 1, 2));

            this.Background = BrushExt.CreateGradientBrush(119, 136, 153, 50, 0, 74, 87, 100, 70, .5, 0, 0, 1, 1);

            #region Horizontal Bar Buttons

            //ARROW IMAGE BUTTON 1
            //Geometry example sourced from Syncfusion Metro Studio 2 - copyright free icons
             TransformGroup traGrp = new TransformGroup();
             traGrp.Children.Add(new RotateTransform(){ Angle = 0 });
             traGrp.Children.Add(new ScaleTransform(){ ScaleX = 1, ScaleY=1 });

             var myPath = new System.Windows.Shapes.Path() { Data = Geometry.Parse(@"F1M646.688,13.5518L646.783,13.4593 646.965,13.639 668.383,35.0583 689.459,35.0583 665.155,10.751 657.503,3.10126 657.323,2.92023 664.876,-4.63837 689.184,-28.9417 668.109,-28.9417 646.688,-7.52637 636.15,3.01398 646.688,13.5518z"), Stretch = Stretch.Uniform, Fill = BrushExt.CreateSolidColorBrushFromString("#FFFFFFFF"), Width = 26D, Height = 26D, Margin = new Thickness(0), RenderTransformOrigin = new Point(0.5, 0.5), RenderTransform = traGrp };

             Grid arrowImageButton1 = FlatButtonHelpers.CreateGridContainerForPath(48, 48, BrushExt.CreateSolidColorBrushFromString("#FF002050"), myPath,
                     (sender, e) =>
                     {
                         Grid source1 = null;
                         Path source2 = null;
                         if (sender is Grid)
                         {
                             source1 = sender as Grid;
                             source2 = source1.Children[0] as Path;
                         }
                         else
                         {
                             source2 = sender as Path;
                             source1 = (sender as Path).Parent as Grid;
                         }

                         if (source1.IsMouseDirectlyOver || source2.IsMouseDirectlyOver)
                         { 
                             source1.Background = Brushes.WhiteSmoke; source2.Fill = Brushes.Silver; 
                         }
                         else 
                         { 
                             source1.Background = BrushExt.CreateSolidColorBrushFromString("#FF002050"); 
                             source2.Fill = BrushExt.CreateSolidColorBrushFromString("#FFFFFFFF"); 
                         }
                     },
                     (o, ev) =>
                     {
                         scrollToFirstItemInGrid(ccl3dBorder1, masterDetail);
                     }                 
                 ,"Scroll to First Item");

             //ARROW IMAGE BUTTON 2
             //Geometry example sourced from Syncfusion Metro Studio 2 - copyright free icons
             TransformGroup traGrp2 = new TransformGroup();
             traGrp2.Children.Add(new RotateTransform() { Angle = 0 });
             traGrp2.Children.Add(new ScaleTransform() { ScaleX = 1, ScaleY = 1 });

             var myPath2 = new Path() { Data = Geometry.Parse(@"F1M568.254,-7.43524L568.159,-7.34277 567.977,-7.52246 546.559,-28.9417 525.484,-28.9417 549.787,-4.63446 557.439,3.01532 557.619,3.19629 550.067,10.7549 525.758,35.0583 546.834,35.0583 568.254,13.6429 578.792,3.10254 568.254,-7.43524z" ), Stretch = Stretch.Uniform, Fill = BrushExt.CreateSolidColorBrushFromString("#FFFFFFFF"), Width = 26D, Height = 26D, Margin = new Thickness(0), RenderTransformOrigin = new Point(0.5, 0.5), RenderTransform = traGrp2 };

             Grid arrowImageButton2 = FlatButtonHelpers.CreateGridContainerForPath(48, 48, BrushExt.CreateSolidColorBrushFromString("#FF002050"), myPath2,
                     (sender, e) =>
                     {
                         Grid source1 = null;
                         Path source2 = null;
                         if (sender is Grid)
                         {
                             source1 = sender as Grid;
                             source2 = source1.Children[0] as Path;
                         }
                         else
                         {
                             source2 = sender as Path;
                             source1 = (sender as Path).Parent as Grid;
                         }

                         if (source1.IsMouseDirectlyOver || source2.IsMouseDirectlyOver)
                         {
                             source1.Background = Brushes.WhiteSmoke; source2.Fill = Brushes.Silver;
                         }
                         else
                         {
                             source1.Background = BrushExt.CreateSolidColorBrushFromString("#FF002050");
                             source2.Fill = BrushExt.CreateSolidColorBrushFromString("#FFFFFFFF");
                         }
                     },
                     (o, ev) =>
                     {
                         scrollToLastItemInGrid(ccl3dBorder1, masterDetail);
                     }
                 ,"Scroll to Last Item");

             //POPUP IMAGE BUTTON 3
             //Geometry example sourced from Syncfusion Metro Studio 2 - copyright free icons
             TransformGroup traGrp3 = new TransformGroup();
             traGrp3.Children.Add(new RotateTransform() { Angle = 0 });
             traGrp3.Children.Add(new ScaleTransform() { ScaleX = 1, ScaleY = 1 });

             var myPath3 = new Path() { Data = Geometry.Parse(@"M5.2010002,14.812L5.2010002,43.573997 56.098,43.573997 56.098,14.812z M29.868601,3.8869994C28.026201,3.8869996 26.534,5.3791947 26.534,7.2190399 26.534,9.0588851 28.026201,10.553 29.868601,10.553 31.7085,10.553 33.202,9.0588851 33.202,7.2190399 33.202,5.3791947 31.7085,3.8869996 29.868601,3.8869994z M19.200649,3.8869994C17.359457,3.8869996 15.867001,5.3791947 15.867001,7.2190399 15.867001,9.0588851 17.359457,10.553 19.200649,10.553 21.042044,10.553 22.536999,9.0588851 22.536999,7.2190399 22.536999,5.3791947 21.042044,3.8869996 19.200649,3.8869994z M8.5339746,3.8869994C6.6931,3.8869996 5.2010002,5.3791947 5.2010002,7.2190399 5.2010002,9.0588851 6.6931,10.553 8.5339746,10.553 10.37495,10.553 11.867,9.0588851 11.867,7.2190399 11.867,5.3791947 10.37495,3.8869996 8.5339746,3.8869994z M0,0L63.999001,0 63.999001,48.792999 0,48.792999z"), Stretch = Stretch.Uniform, Fill = BrushExt.CreateSolidColorBrushFromString("#FFFFFFFF"), Width = 26D, Height = 26D, Margin = new Thickness(0), RenderTransformOrigin = new Point(0.5, 0.5), RenderTransform = traGrp3 };

             Grid arrowImageButton3 = FlatButtonHelpers.CreateGridContainerForPath(48, 48, BrushExt.CreateSolidColorBrushFromString("#FF002050"), myPath3,
                     (sender, e) =>
                     {
                         Grid source1 = null;
                         Path source2 = null;
                         if (sender is Grid)
                         {
                             source1 = sender as Grid;
                             source2 = source1.Children[0] as Path;
                         }
                         else
                         {
                             source2 = sender as Path;
                             source1 = (sender as Path).Parent as Grid;
                         }

                         if (source1.IsMouseDirectlyOver || source2.IsMouseDirectlyOver)
                         {
                             source1.Background = Brushes.WhiteSmoke; source2.Fill = Brushes.Silver;
                         }
                         else
                         {
                             source1.Background = BrushExt.CreateSolidColorBrushFromString("#FF002050");
                             source2.Fill = BrushExt.CreateSolidColorBrushFromString("#FFFFFFFF");
                         }
                     },
                     (o, ev) =>
                     {
                        // pop1.IsOpen = !pop1.IsOpen;

                         if (masterDetail.Visibility == Visibility.Visible)
                         {
                             masterDetail.Visibility = Visibility.Collapsed;
                             borderwithRectangle.Visibility = Visibility.Collapsed;
                         }
                         else
                         {
                             masterDetail.Visibility = Visibility.Visible;
                             borderwithRectangle.Visibility = Visibility.Visible;
                         }

                       //testing out recursing up parents here . . .
                       //var xx=  masterDetail.GetChildLookupDictionary().Values.First() as TextBlock;
                       //var yy= xx.Inlines.First() as Run;
                       //MessageBox.Show(yy.ToString());
                       //var xtx = Selectors.RecurseUpParentFrameworkElementsDepObj(false, 3000, yy as DependencyObject);
                       //MessageBox.Show(xtx.ToString());
                     }
                 , "Toggle DataGrid");

             //HELP IMAGE BUTTON 4
             //Geometry example sourced from Syncfusion Metro Studio 2 - copyright free icons
             TransformGroup traGrp4 = new TransformGroup();
             traGrp4.Children.Add(new RotateTransform() { Angle = 0 });
             traGrp4.Children.Add(new ScaleTransform() { ScaleX = 1, ScaleY = 1 });

             var myPath4 = new Path() { Data = Geometry.Parse(@"F1M1355.27,1727.8L1346.08,1727.8C1346.06,1726.48 1346.05,1725.67 1346.05,1725.38 1346.05,1722.41 1346.54,1719.96 1347.52,1718.04 1348.51,1716.12 1350.47,1713.96 1353.43,1711.56 1356.38,1709.16 1358.14,1707.58 1358.72,1706.84 1359.61,1705.66 1360.05,1704.37 1360.05,1702.95 1360.05,1700.98 1359.27,1699.29 1357.7,1697.89 1356.12,1696.49 1354,1695.78 1351.34,1695.78 1348.77,1695.78 1346.62,1696.52 1344.89,1697.98 1343.16,1699.44 1341.98,1701.68 1341.33,1704.68L1332.04,1703.53C1332.3,1699.23 1334.13,1695.58 1337.53,1692.58 1340.93,1689.58 1345.38,1688.08 1350.91,1688.08 1356.72,1688.08 1361.34,1689.6 1364.77,1692.63 1368.21,1695.67 1369.92,1699.2 1369.92,1703.24 1369.92,1705.47 1369.29,1707.58 1368.03,1709.58 1366.77,1711.57 1364.08,1714.28 1359.95,1717.71 1357.81,1719.49 1356.48,1720.92 1355.97,1722 1355.45,1723.08 1355.22,1725.01 1355.27,1727.8z M1346.08,1741.41L1346.08,1731.29 1356.2,1731.29 1356.2,1741.41 1346.08,1741.41z" ), Stretch = Stretch.Uniform, Fill = BrushExt.CreateSolidColorBrushFromString("#FFFFFFFF"), Width = 26D, Height = 26D, Margin = new Thickness(0), RenderTransformOrigin = new Point(0.5, 0.5), RenderTransform = traGrp4};

             Grid arrowImageButton4 = FlatButtonHelpers.CreateGridContainerForPath(48, 48, BrushExt.CreateSolidColorBrushFromString("#FF002050"), myPath4,
                     (sender, e) =>
                     {
                         Grid source1 = null;
                         Path source2 = null;
                         if (sender is Grid)
                         {
                             source1 = sender as Grid;
                             source2 = source1.Children[0] as Path;
                         }
                         else
                         {
                             source2 = sender as Path;
                             source1 = (sender as Path).Parent as Grid;
                         }

                         if (source1.IsMouseDirectlyOver || source2.IsMouseDirectlyOver)
                         {
                             source1.Background = Brushes.WhiteSmoke; source2.Fill = Brushes.Silver;
                         }
                         else
                         {
                             source1.Background = BrushExt.CreateSolidColorBrushFromString("#FF002050");
                             source2.Fill = BrushExt.CreateSolidColorBrushFromString("#FFFFFFFF");
                         }
                     },
                     (o, ev) =>
                     {
                         pop1.IsOpen = !pop1.IsOpen;
                     }
                 , "Help (click and hold to display)");

             //HELP IMAGE BUTTON 5
             //Geometry example sourced from Syncfusion Metro Studio 2 - copyright free icons
             TransformGroup traGrp5 = new TransformGroup();
             traGrp5.Children.Add(new RotateTransform() { Angle = 0 });
             traGrp5.Children.Add(new ScaleTransform() { ScaleX = 1, ScaleY = 1 });

             var myPath5 = new Path() { Data = Geometry.Parse(@"M19.833,0L32.501,0 32.501,19.833999 52.334,19.833999 52.334,32.500999 32.501,32.500999 32.501,52.333 19.833,52.333 19.833,32.500999 0,32.500999 0,19.833999 19.833,19.833999z"), Stretch = Stretch.Uniform, Fill = BrushExt.CreateSolidColorBrushFromString("#FFFFFFFF"), Width = 26D, Height = 26D, Margin = new Thickness(0), RenderTransformOrigin = new Point(0.5, 0.5), RenderTransform = traGrp5 };

             Grid arrowImageButton5 = FlatButtonHelpers.CreateGridContainerForPath(48, 48, BrushExt.CreateSolidColorBrushFromString("#FF002050"), myPath5,
                     (sender, e) =>
                     {
                         Grid source1 = null;
                         Path source2 = null;
                         if (sender is Grid)
                         {
                             source1 = sender as Grid;
                             source2 = source1.Children[0] as Path;
                         }
                         else
                         {
                             source2 = sender as Path;
                             source1 = (sender as Path).Parent as Grid;
                         }

                         if (source1.IsMouseDirectlyOver || source2.IsMouseDirectlyOver)
                         {
                             source1.Background = Brushes.WhiteSmoke; source2.Fill = Brushes.Silver;
                         }
                         else
                         {
                             source1.Background = BrushExt.CreateSolidColorBrushFromString("#FF002050");
                             source2.Fill = BrushExt.CreateSolidColorBrushFromString("#FFFFFFFF");
                         }
                     },
                     (o, ev) =>
                     {
                         ccl3dBorder1.GetChildFromComposite<TextBox, ContentControl3D>(1, 1).Text = String.Empty;
                         ccl3dBorder1.GetChildFromComposite<ComboBox, ContentControl3D>(3, 1).Text = String.Empty;
                         ccl3dBorder1.GetChildFromComposite<TextBox, ContentControl3D>(4, 1).Text = String.Empty;
                         ccl3dBorder1.GetChildFromComposite<TextBox, ContentControl3D>(5, 1).Text = String.Empty;

                         currentEntity = new Travel();
                         currentEntity.ID = Guid.NewGuid().ToString();
                         currentEntity.ParkingGarages = new List<ParkingGarage>();
                         currentEntity.ParkingGarages.Add(new ParkingGarage() { ID = Guid.NewGuid().ToString(), ParentID = currentEntity.ID });
                     }
                 , "Add");

             pop1.Initialize(134D, 300D, ContainerType.VerticalPanel, false, arrowImageButton4, PopupAnimation.Scroll, false);
             pop1.BeginComposite<Popup>()
                 .AddExisting<Label, Popup>(0, 0, myHelp)
                 .EndComposite<Popup, PopupArgs>(null);


             //Save IMAGE BUTTON 6
             //Geometry example sourced from Syncfusion Metro Studio 2 - copyright free icons
             TransformGroup traGrp6 = new TransformGroup();
             traGrp6.Children.Add(new RotateTransform() { Angle = 0 });
             traGrp6.Children.Add(new ScaleTransform() { ScaleX = 1, ScaleY = 1 });

             var myPath6 = new Path() { Data = Geometry.Parse(@"M8.1099597,36.94997L8.1099597,41.793968 39.213959,41.793968 39.213959,36.94997z M12.42,0.049999889L18.4,0.049999889 18.4,12.252 12.42,12.252z M0,0L7.9001866,0 7.9001866,14.64218 39.210766,14.64218 39.210766,0 47.401001,0 47.401001,47.917 0,47.917z"), Stretch = Stretch.Uniform, Fill = BrushExt.CreateSolidColorBrushFromString("#FFFFFFFF"), Width = 26D, Height = 26D, Margin = new Thickness(0), RenderTransformOrigin = new Point(0.5, 0.5), RenderTransform = traGrp6 };

             Grid saveButton6 = FlatButtonHelpers.CreateGridContainerForPath(48, 48, BrushExt.CreateSolidColorBrushFromString("#FF002050"), myPath6,
                     (sender, e) =>
                     {
                         Grid source1 = null;
                         Path source2 = null;
                         if (sender is Grid)
                         {
                             source1 = sender as Grid;
                             source2 = source1.Children[0] as Path;
                         }
                         else
                         {
                             source2 = sender as Path;
                             source1 = (sender as Path).Parent as Grid;
                         }

                         if (source1.IsMouseDirectlyOver || source2.IsMouseDirectlyOver)
                         {
                             source1.Background = Brushes.WhiteSmoke; source2.Fill = Brushes.Silver;
                         }
                         else
                         {
                             source1.Background = BrushExt.CreateSolidColorBrushFromString("#FF002050");
                             source2.Fill = BrushExt.CreateSolidColorBrushFromString("#FFFFFFFF");
                         }
                     },
                     (o, ev) =>
                     {
                         // pop1.IsOpen = !pop1.IsOpen;
                         if (currentEntity != null)
                         {
                             if (isValid(ccl3dBorder1, ccl3d))
                             {
                                 currentEntity.Attraction = ccl3dBorder1.GetChildFromComposite<TextBox, ContentControl3D>(1, 1).Text; //Attraction
                                 // currentEntity.Parking = ccl3dBorder1.GetChildFromComposite<ComboBox, ContentControl3D>(3, 1).Text = String.Empty; //Parking
                                 currentEntity.Flight = ccl3dBorder1.GetChildFromComposite<TextBox, ContentControl3D>(4, 1).Text; //Flight
                                 currentEntity.Hotel = ccl3dBorder1.GetChildFromComposite<TextBox, ContentControl3D>(5, 1).Text; //Hotel
                                 currentEntity.ParkingGarages[0].Color = ccl3dBorder1.GetChildFromComposite<ComboBox, ContentControl3D>(3, 1).Text;

                                 currentEntity.ParkingGarages[0].Description = ccl3dBorder1.GetChildFromComposite<ComboBox, ContentControl3D>(3, 1).GetChildFromParent<TextBlock, ComboBox>(ccl3dBorder1.GetChildFromComposite<ComboBox, ContentControl3D>(3, 1).SelectedBorder().GetKey(), 1, 0).GetText();

                                 int rowCount = (masterDetail.Items.Count);
                                 string rowGuid0 = currentEntity.ID;

                                 //Column 1
                                 var borderJ = masterDetail.BeginComposite<DataGrid>(rowGuid0 + "1")
                                         .AddText(0, 0, (masterDetail.Items.Count).ToString())
                                         .AddText(0, 1, "Flight: " + currentEntity.Flight)
                                         .AddText(0, 2, "Hotel: " + currentEntity.Hotel)
                                         .AddText(0, 3, "Attraction: " + " " + currentEntity.Attraction)
                                         .AddLabel(0, 4, "Newly Add", Brushes.Khaki)
                                         .SetMouseOverColorOnContainer<StackPanel, DataGrid>(Brushes.Silver)
                                         .EndComposite<DataGrid, DataGridArgs>(new DataGridArgs(rowGuid0, rowCount, 0));

                                 //Column 2
                                 masterDetail.BeginComposite<DataGrid>(rowGuid0 + "2")
                                         .AddText(0, 0, "Color: " + currentEntity.ParkingGarages[0].Color)
                                         .AddText(0, 1, "Description: " + currentEntity.ParkingGarages[0].Description)
                                         .AddText(0, 2, " ")
                                         .SetMouseOverColorOnContainer<StackPanel, DataGrid>(Brushes.Silver)
                                         .EndComposite<DataGrid, DataGridArgs>(new DataGridArgs(rowGuid0, rowCount, 1));


                                 masterDetail.UpdateByKey<TextBlock, DataGrid>(borderJ.GetKey(), 0, 0, txt => { txt.FontWeight = FontWeights.Bold; });
                                 masterDetail.SelectedIndex = masterDetail.Items.Count - 1;
                                 masterDetail.ScrollIntoView(masterDetail.Items[masterDetail.Items.Count - 1]);
                                 currentEntity = null;
                             }
                             else
                             {
                                 MessageBox.Show("Parking Garages field must not be blank!");
                             }
                         }
                         else
                         {
                             MessageBox.Show("You must first click 'Add' to create a new Travel record!");
                         }
                     }
                 , "Save");

            #endregion

             //Add Label and StackPanel
             this.BeginComposite<UserControl>(_userCtlGuid)
                 .AddExisting<Label, UserControl>(0, 0, myTabLabel)
                 .AddAnyIParent<StackPanel, UserControl>(0, 1, stackPanelBar =>
                 {
                     stackPanelBar.Initialize(Double.NaN, 48D, ContainerType.VerticalPanel, Orientation.Horizontal);
                     stackPanelBar.BeginSettings<StackPanel>().SetItemBorderSettings(Double.NaN, 48D, Brushes.Silver, new Thickness(1))
                     .Set<Grid, StackPanel>(0, 0, "HorizontalAlignment", HorizontalAlignment.Left).EndSettings();

                     stackPanelBar.BeginComposite<StackPanel>()
                    .AddExisting<Grid, StackPanel>(0, 0, arrowImageButton1)
                    .EndComposite<StackPanel, StackPanelArgs>(null);

                     stackPanelBar.BeginComposite<StackPanel>()
                    .AddExisting<Grid, StackPanel>(0, 1, arrowImageButton2)
                    .EndComposite<StackPanel, StackPanelArgs>(null);
            
                     stackPanelBar.BeginComposite<StackPanel>()
                    .AddExisting<Grid, StackPanel>(0, 2, arrowImageButton5)
                    .EndComposite<StackPanel, StackPanelArgs>(null);

                     stackPanelBar.BeginComposite<StackPanel>()
                    .AddExisting<Grid, StackPanel>(0, 3, saveButton6)
                    .EndComposite<StackPanel, StackPanelArgs>(null);

                     stackPanelBar.BeginComposite<StackPanel>()
                    .AddExisting<Grid, StackPanel>(0, 4, arrowImageButton3)
                    .EndComposite<StackPanel, StackPanelArgs>(null);

                     stackPanelBar.BeginComposite<StackPanel>()
                    .AddExisting<Grid, StackPanel>(0, 5, arrowImageButton4)
                    .EndComposite<StackPanel, StackPanelArgs>(null);
                 })
                 .AddExisting<Canvas, UserControl>(0, 2, userControlCanvas)
                 .EndComposite<UserControl, UserControlArgs>(null);

            FrameworkElement fe = this.SelectAllFrameworkElementsByClass("tabLabel", false).First();

            Label compositeX = ccl3dBorder1.GetChildFromComposite<Label, ContentControl3D>(10, 0);

            compositeX.DataBindOneChildsPropertyToFE<Label, Label>(fe, Border.BackgroundProperty, Label.BackgroundProperty, System.Windows.Data.UpdateSourceTrigger.PropertyChanged, System.Windows.Data.BindingMode.OneWay);

           // compositeX.DataBindOneChildsPropertyToFEViaStyle<Label, Label>(fe, Border.BackgroundProperty, Label.BackgroundProperty, System.Windows.Data.UpdateSourceTrigger.PropertyChanged, System.Windows.Data.BindingMode.OneWay);

        //    compositeX.DataBindOneChildsPropertyToFEViaTrigger<Label, Label>(fe, Border.BackgroundProperty, Label.BackgroundProperty, System.Windows.Data.UpdateSourceTrigger.PropertyChanged, System.Windows.Data.BindingMode.OneWay, FrameworkElement.IsMouseOverProperty, true);

       //     ccl3dBorder1.DataBindBordersPropertyToFE<Label>(fe, Border.BackgroundProperty, Label.BackgroundProperty, System.Windows.Data.UpdateSourceTrigger.PropertyChanged, System.Windows.Data.BindingMode.OneWay);


            //Selectors.SelectAllFrameworkElementsByClass(this, "redlabel", false).ForEach(fe => { if (fe is Label && ((Label)fe).Content.ToString().Contains("n:")) { (fe as Label).Background = Brushes.Red; }
            //if (fe is TextBox) { (fe as TextBox).Background = Brushes.Red; }
            //});

            // this.DisposeEventsOnAllParents();

            //Since TabItem10 is still being built, you can't traverse up via the Selectors engine, so get a handle to the Window via handle stored on Application.Current.

            //Window mainWindow = (Window)Application.Current.Properties["Window"];
            //FasterWPF.Observables.ObservableHelper.BindObservableSelectedByClassName<TextBlock, DataGrid, MouseButtonEventArgs>(mainWindow, "MagicParent", "magic", "PreviewMouseDown", eventPattern =>
            //{

            //    Canvas canVas = (Canvas)Application.Current.Properties["Canvas"];
            //    FasterWPF.Dialogs.DialogHelpers.ShowOKDialog(canVas, Guid.NewGuid().ToString(), "Bind via Selector Class Example", 175.0D, 150.0D, 150.0D,
            //        Brushes.Black, new Thickness(1), Brushes.Silver, Brushes.Blue, Brushes.White, Brushes.Silver, Brushes.Gray, true);
            //}); 



            Window mainWindow = (Window)Application.Current.Properties["Window"];
            FasterWPF.Observables.ObservableHelper.SubscribeDepEventByClassName<TextBlock, DataGrid, MouseButtonEventArgs>(mainWindow, "MagicParent", "magic", "IsMouseDirectlyOverChanged", eventPattern =>
            {
                Canvas canVas = (Canvas)Application.Current.Properties["Canvas"];
                FasterWPF.Dialogs.DialogHelpers.ShowOKDialog(canVas, Application.Current.Properties["DialogGuid"].ToString(), "Bind via Selector Class Example", 175.0D, 150.0D, 150.0D,
                    Brushes.Black, new Thickness(1), Brushes.Silver, Brushes.Blue, Brushes.White, Brushes.Silver, Brushes.Gray, true);

            }, (connectableObservable, actionDelegate) => { connectableObservable.Skip(15).Subscribe(actionDelegate); });
            
                Canvas canVas2 = (Canvas)Application.Current.Properties["Canvas"];
            //    FasterWPF.Dialogs.DialogHelpers.ShowOKDialog(canVas, Guid.NewGuid().ToString(), "Bind via Selector Class Example", 175.0D, 150.0D, 150.0D,
            //        Brushes.Black, new Thickness(1), Brushes.Silver, Brushes.Blue, Brushes.White, Brushes.Silver, Brushes.Gray, true);


            FasterWPF.Dialogs.DialogHelpers.ShowYesNoCancelDialog(canVas2, Application.Current.Properties["DialogGuid"].ToString(), "Bind via Selector Class Example", 175.0D, 150.0D, 150.0D,
                    Brushes.Black, new Thickness(1), Brushes.Silver, Brushes.WhiteSmoke, Brushes.White, Brushes.Silver, Brushes.Gray, true,
                    result => { MessageBox.Show(result.ToString()); });



            //FasterWPF.Observables.ObservableHelper.FireObservableOnParent<MouseButtonEventArgs, DataGrid>(masterDetail, "PreviewMouseDown", new MouseButtonEventArgs(Mouse.PrimaryDevice, 100, MouseButton.Left));
        }

        private static void scrollToLastItemInGrid(Border ccl3dBorder1, DataGrid masterDetail)
        {
            masterDetail.SelectedIndex = masterDetail.Items.Count - 1;
            masterDetail.ScrollIntoView(masterDetail.Items[masterDetail.Items.Count - 1]);


            //ON SELECTION CHANGED, UPDATE THE DETAIL RECORD
            DataGridRow selectedRow = masterDetail.GetSelectedRow();
            if (selectedRow != null)
            {
                var cells = selectedRow.Item as ColumnContent<Border, Border, Border, Border, Border, Border, Border, Border, Border, Border, Border>;
                Border contentAtCol0 = cells.Content0.Content as Border;
                Border contentAtCol1 = cells.Content1.Content as Border;

                char colon = ':';

                //NOTE: y/column is the index for StackPanel. x/row is ignored.

                string flight = contentAtCol0.GetChildFromComposite<TextBlock, DataGrid>(0, 1).GetText().Split(colon)[1].Trim();
                string hotel = contentAtCol0.GetChildFromComposite<TextBlock, DataGrid>(0, 2).GetText().Split(colon)[1].Trim();
                string attraction = contentAtCol0.GetChildFromComposite<TextBlock, DataGrid>(0, 3).GetText().Split(colon)[1].Trim();
                string parking = contentAtCol1.GetChildFromComposite<TextBlock, DataGrid>(0, 0).GetText().Split(colon)[1].Trim();

                ccl3dBorder1.GetChildFromComposite<TextBox, ContentControl3D>(1, 1).Text = attraction;
                ccl3dBorder1.GetChildFromComposite<ComboBox, ContentControl3D>(3, 1).Text = parking;
                ccl3dBorder1.GetChildFromComposite<TextBox, ContentControl3D>(4, 1).Text = flight;
                ccl3dBorder1.GetChildFromComposite<TextBox, ContentControl3D>(5, 1).Text = hotel;
            }
        }

        private static void scrollToFirstItemInGrid(Border ccl3dBorder1, DataGrid masterDetail)
        {
            masterDetail.SelectedIndex = 0;
            masterDetail.ScrollIntoView(masterDetail.Items[0]);



            //ON SELECTION CHANGED, UPDATE THE DETAIL RECORD
            DataGridRow selectedRow = masterDetail.GetSelectedRow();
            if (selectedRow != null)
            {
                var cells = selectedRow.Item as ColumnContent<Border, Border, Border, Border, Border, Border, Border, Border, Border, Border, Border>;
                Border contentAtCol0 = cells.Content0.Content as Border;
                Border contentAtCol1 = cells.Content1.Content as Border;

                char colon = ':';

                //NOTE: y/column is the index for StackPanel. x/row is ignored.

                string flight = contentAtCol0.GetChildFromComposite<TextBlock, DataGrid>(0, 1).GetText().Split(colon)[1].Trim();
                string hotel = contentAtCol0.GetChildFromComposite<TextBlock, DataGrid>(0, 2).GetText().Split(colon)[1].Trim();
                string attraction = contentAtCol0.GetChildFromComposite<TextBlock, DataGrid>(0, 3).GetText().Split(colon)[1].Trim();
                string parking = contentAtCol1.GetChildFromComposite<TextBlock, DataGrid>(0, 0).GetText().Split(colon)[1].Trim();

                ccl3dBorder1.GetChildFromComposite<TextBox, ContentControl3D>(1, 1).Text = attraction;
                ccl3dBorder1.GetChildFromComposite<ComboBox, ContentControl3D>(3, 1).Text = parking;
                ccl3dBorder1.GetChildFromComposite<TextBox, ContentControl3D>(4, 1).Text = flight;
                ccl3dBorder1.GetChildFromComposite<TextBox, ContentControl3D>(5, 1).Text = hotel;
            }
        }

        public bool isValid(Border compositeToValidate, ContentControl3D ccl3d)
        {        
            bool tempResult = false;
            
            //Validate Fields Example
            if (compositeToValidate.GetChildFromComposite<ComboBox, ContentControl3D>(3, 1).Text == null || (compositeToValidate.GetChildFromComposite<ComboBox, ContentControl3D>(3, 1).Text == String.Empty))
            {
                AdornerDecoratorExt.DisplayErrorRectangle(compositeToValidate.GetChildFromComposite<ComboBox, ContentControl3D>(3, 1), AdornerLayer.GetAdornerLayer(this), 43D, -1D, 34D, -1D, Brushes.Blue);
            }
            else
            {
                AdornerDecoratorExt.RemoveErrorRectangle(compositeToValidate.GetChildFromComposite<ComboBox, ContentControl3D>(3, 1), AdornerLayer.GetAdornerLayer(this));
                tempResult=true;
            }

            return tempResult;
        }

        public ComboBox SetupComboBox()
        {
            ComboBox cb1 = new ComboBox();

            string cbGuid1 = Guid.NewGuid().ToString();
            string cbGuid2 = Guid.NewGuid().ToString();
            string cbGuid3 = Guid.NewGuid().ToString();
            string cbGuid4 = Guid.NewGuid().ToString();
            string cbGuid5 = Guid.NewGuid().ToString();
            string cbGuid6 = Guid.NewGuid().ToString();
            string cbGuid7 = Guid.NewGuid().ToString();
            string cbGuid8 = Guid.NewGuid().ToString();
            string cbGuid9 = Guid.NewGuid().ToString();   

            cb1.Initialize(139D, 30, ContainerType.Grid, 1, 1, 150D, ComboStyles.TypeAheadSelectableButAcceptsAnyText, Brushes.Black, Brushes.Silver); //set CanContentScroll to false and ScrollViewer Height to 150        

            ScrollViewerStyle.ApplyToScrollViewer<ComboBox>(cb1, "Blue", "Silver", "Blue");
            
            cb1.SetCompositeGridDimensions<ComboBox>(2, 1, 150, GridUnitType.Pixel, 25, GridUnitType.Pixel);
            cb1.BeginSettings<ComboBox>().SetItemBorderSettings<ComboBox>(150, 50, Brushes.Black, new Thickness(2)).EndSettings<ComboBox>();
      //      cb1.SubscribeEventOnParent<ComboBox>("SelectionChanged", new SelectionChangedEventHandler(cb1_SelectionChanged));

            //test ability to unsubscribe
            //cb1.UnsubscribeSelectionChangedOnParent<ComboBox>();

         var cbb1 = cb1.BeginComposite<ComboBox>(cbGuid1).AddText(0, 0, "Blue").AddText(1, 0, "Blue as water.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
         var cbb2 = cb1.BeginComposite<ComboBox>(cbGuid2).AddText(0, 0, "Red").AddText(1, 0, "Red as apple.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
         var cbb3 = cb1.BeginComposite<ComboBox>(cbGuid3).AddText(0, 0, "Green").AddText(1, 0, "Green as grass.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
         var cbb4 = cb1.BeginComposite<ComboBox>(cbGuid4).AddText(0, 0, "Orange").AddText(1, 0, "Orange as pumpkin.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
            cb1.BeginComposite<ComboBox>(cbGuid5).AddText(0, 0, "Yellow").AddText(1, 0, "Yellow as taxicab.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
            cb1.BeginComposite<ComboBox>(cbGuid6).AddText(0, 0, "Purple").AddText(1, 0, "Purple as grape.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
            cb1.BeginComposite<ComboBox>(cbGuid7).AddText(0, 0, "Brown").AddText(1, 0, "Brown as dirt.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
            cb1.BeginComposite<ComboBox>(cbGuid8).AddText(0, 0, "Black").AddText(1, 0, "Black as midnight.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
            cb1.BeginComposite<ComboBox>(cbGuid9).AddText(0, 0, "Silver").AddText(1, 0, "Silver as lining.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));

            cb1.SetSelectedKey(cbGuid3);
            cb1.GetChildFromParent<TextBlock, ComboBox>(cbGuid1, 1, 0).Background = Brushes.Blue;
            cb1.GetChildFromParent<TextBlock, ComboBox>(cbGuid2, 1, 0).Background = Brushes.Red;

           // cb1.GetContainerFromComposite<Grid, ComboBox>(cbb1).Background = Brushes.Goldenrod;
           // cb1.Background = Brushes.Green;

            cbb1.Background = Brushes.Purple;

            //experiment with DataBinding features . . .
            cbb1.DataBindOneChildsPropertyToBorders<TextBlock, ComboBox>(cbGuid1, 1, 0, TextBlock.BackgroundProperty, Border.BackgroundProperty, System.Windows.Data.UpdateSourceTrigger.PropertyChanged, System.Windows.Data.BindingMode.OneWay);
            cbb2.DataBindBordersPropertyToOneChilds<TextBlock, ComboBox>(cbGuid2, 1, 0, Border.BackgroundProperty, TextBlock.BackgroundProperty, System.Windows.Data.UpdateSourceTrigger.PropertyChanged, System.Windows.Data.BindingMode.OneWay);

            BrushTest brTest = new BrushTest();
            brTest.BrushProperty = Brushes.Turquoise;
            cbb3.DataBindBordersPropertyToDepObj(brTest, Border.BackgroundProperty, BrushTest.BrushPropertyProperty, System.Windows.Data.UpdateSourceTrigger.PropertyChanged, System.Windows.Data.BindingMode.OneWay);

            BrushTest brTest3 = new BrushTest();
            brTest3.BrushProperty = Brushes.Orange;
            TextBlock tl349 = cb1.GetChildFromParent<TextBlock, ComboBox>(cbGuid4, 1, 0);
            tl349.DataBindOneChildsPropertyToDepObj<TextBlock>(brTest3, TextBlock.BackgroundProperty, BrushTest.BrushPropertyProperty, System.Windows.Data.UpdateSourceTrigger.PropertyChanged, System.Windows.Data.BindingMode.OneWay);
            brTest3.BrushProperty = Brushes.Pink;
            return cb1;
        }

        #region Data

        private int populateTravelEntities(List<Travel> tListTreeView, int i, int x)
        {
            int j = i;

            List<ParkingGarage> pgList = new List<ParkingGarage>();

            pgList.Add(new ParkingGarage()
            {
                ID = Guid.NewGuid().ToString(),
                Color = "Silver",
                Description = "Silver as Lining"
            });

            List<ParkingGarage> pgList2 = new List<ParkingGarage>();

            pgList2.Add(new ParkingGarage()
            {
                ID = Guid.NewGuid().ToString(),
                Color = "Blue",
                Description = "Blue as Water"
            });

            List<ParkingGarage> pgList3 = new List<ParkingGarage>();

            pgList3.Add(new ParkingGarage()
            {
                ID = Guid.NewGuid().ToString(),
                Color = "Black",
                Description = "Black as Midnight"
            });


            List<ParkingGarage> pgList4 = new List<ParkingGarage>();

            pgList4.Add(new ParkingGarage()
            {
                ID = Guid.NewGuid().ToString(),
                Color = "Green",
                Description = "Green as Grass"
            });

            if (i == 1)
            {
                tListTreeView.Add(new Travel()
                {
                    ID = Guid.NewGuid().ToString(),
                    Attraction = "Microsoft Headquarters",
                    Flight = "SEA",
                    Hotel = "Hilton",
                    ParkingGarages = pgList,
                    Counter = x
                });
            }
            else if (i == 2)
            {
                tListTreeView.Add(new Travel()
                {
                    ID = Guid.NewGuid().ToString(),
                    Attraction = "The Galleria",
                    Flight = "HOU",
                    Hotel = "Marriott",
                    ParkingGarages = pgList2,
                    Counter = x
                });
            }
            else if (i == 3)
            {
                tListTreeView.Add(new Travel()
                {
                    ID = Guid.NewGuid().ToString(),
                    Attraction = "Statue of Liberty",
                    Flight = "LGA",
                    Hotel = "Ritz-Carlton",
                    ParkingGarages = pgList3,
                    Counter = x
                });
            }
            else
            {
                tListTreeView.Add(new Travel()
                {
                    ID = Guid.NewGuid().ToString(),
                    Attraction = "Lake Michigan",
                    Flight = "ORD",
                    Hotel = "Palmer House",
                    ParkingGarages = pgList4,
                    Counter = x
                });
            }

            if (i < 2)
            {
                i++;
            }
            else
            {
                i = 0; //reset
            }
            return i;
        }

        #endregion

    }//end of class
}//end of namespace
